<?php
// +----------------------------------------------------------------------
// | zhanshop-server / http.php    [ 2022/5/1 12:18 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2022 zhangqiquan All rights reserved.
// +----------------------------------------------------------------------
// | Author: Administrator <768617998@qq.com>
// +----------------------------------------------------------------------

use zhanshop\App;
use zhanshop\ServEvent;
use zhanshop\console\command\Server;
use app\api\admin\BridgEvent;
use app\api\admin\HttpProxyEvent;
return [
    'servers' => [
        [
            'name'      => 'admin',
            'mode'      => 2,
            'host'      => App::env()->get("SERV_HOST", "0.0.0.0"),
            'port'      => (int)App::env()->get("BRIDG_PORT", "8202"),
            'sock_type' => (int)App::env()->get("SOCK_TCP_TYPE", "1"),
            'serv_type' => Server::TCP,
            'callbacks' => [
                ServEvent::ON_WORKER_START => [BridgEvent::class, 'onWorkerStart'],
                ServEvent::ON_CONNECT => [BridgEvent::class, 'onConnect'],
                ServEvent::ON_RECEIVE => [BridgEvent::class, 'onReceive'],
                ServEvent::ON_CLOSE => [BridgEvent::class, 'onClose'],
            ],
            'settings' => [
                'send_yield' => false,
                //'open_tcp_nodelay' => true,
                'enable_coroutine' => false, // 这个只是将OnRequest 方法变成非阻塞而已而没有把mysql的操作变成非阻塞
                ///'hook_flags' => SWOOLE_HOOK_ALL,
                'buffer_output_size' => 5 * 1024 * 1024,
                'package_max_length' => 5 * 1024 * 1024,
                'heartbeat_idle_time'      => 60, // 表示一个连接如果600秒内未向服务器发送任何数据，此连接将被强制关闭
                'heartbeat_check_interval' => 60,  // 表示每60秒遍历一次
            ]
        ],
        [
            'name'      => 'httpproxy',
            'mode'      => 2,
            'host'      => App::env()->get("SERV_HOST", "0.0.0.0"),
            'port'      => (int)App::env()->get("HTTP_PROXY_PORT", "8280"),
            'sock_type' => (int)App::env()->get("SOCK_TCP_TYPE", "1"),
            'serv_type' => Server::TCP,
            'callbacks' => [
                ServEvent::ON_CONNECT => [HttpProxyEvent::class, 'onConnect'],
                ServEvent::ON_RECEIVE => [HttpProxyEvent::class, 'onReceive'],
                ServEvent::ON_CLOSE => [HttpProxyEvent::class, 'onClose'],
            ]
        ],
    ],
    'settings' => [
        'worker_num' => 2,
        'reactor_num' => 2,
        'buffer_output_size' => 10 * 1024 * 1024,
        'package_max_length' => 10 * 1024 * 1024,
        'heartbeat_idle_time'      => 120, // 表示一个连接如果600秒内未向服务器发送任何数据，此连接将被强制关闭
        'heartbeat_check_interval' => 60,  // 表示每60秒遍历一次
    ],
    'crontab' => [
    ],
];
